<template>
  <div class="painting-container">
    <div class="background-wrapper"></div>
    <div class="content">
      <!-- 导航栏组件 -->
      <Navbar />

      <!-- AI绘画页面主要内容 -->
      <section class="painting-main">
        <div class="painting-content">
          <h2 class="page-title">AI视觉艺术创作</h2>
          <p class="page-description">
            通过三步式分步引导流程，轻松创作属于您的独特艺术作品
          </p>
          
          <!-- 创作步骤指示器 -->
          <div class="steps-indicator">
            <div 
              v-for="(step, index) in steps" 
              :key="index"
              :class="['step', { active: currentStep >= index, completed: currentStep > index }]"
            >
              <div class="step-number">{{ index + 1 }}</div>
              <div class="step-label">{{ step }}</div>
            </div>
          </div>
          
          <!-- 第一步：风格选择 -->
          <div v-show="currentStep === 0" class="creation-step">
            <h3>选择艺术风格</h3>
            <div class="style-selection">
              <div class="tags-container">
                <div 
                  v-for="style in artStyles" 
                  :key="style"
                  :class="['tag', { selected: selectedStyles.includes(style) }]"
                  @click="toggleStyle(style)"
                >
                  {{ style }}
                </div>
              </div>
              
              <div class="selected-combination" v-if="selectedStyles.length">
                <h4>已选风格组合：</h4>
                <div class="combination-tags">
                  <span v-for="style in selectedStyles" :key="style" class="combination-tag">{{ style }}</span>
                </div>
              </div>
            </div>
            
            <div class="step-actions">
              <button class="next-btn" @click="nextStep" :disabled="!canProceedToStep1">下一步</button>
            </div>
          </div>
          
          <!-- 第二步：关键词引导 -->
          <div v-show="currentStep === 1" class="creation-step">
            <h3>关键词引导</h3>
            <div class="keyword-guidance">
              <div class="recommendation-section" v-if="recommendedKeywords.length">
                <h4>推荐关键词（点击添加）</h4>
                <div class="tags-container">
                  <div 
                    v-for="keyword in recommendedKeywords" 
                    :key="keyword"
                    class="tag recommendation-tag"
                    @click="addKeyword(keyword)"
                  >
                    {{ keyword }}
                  </div>
                </div>
              </div>
              
              <div class="input-section">
                <div class="input-group">
                  <h4>详细创作描述</h4>
                  <textarea 
                    v-model="mainDescription"
                    placeholder="请输入详细的创作描述，例如：'一只穿着宇航服的猫在太空中漫步，背景是绚烂的星云'"
                    class="description-input"
                  ></textarea>
                </div>
                
                <div class="input-group">
                  <h4>自定义关键词</h4>
                  <div class="keyword-input-area">
                    <input 
                      v-model="newKeyword"
                      @keyup.enter="addCustomKeyword"
                      placeholder="输入关键词后按回车添加"
                      class="keyword-input"
                    >
                    <button @click="addCustomKeyword" class="add-keyword-btn">添加</button>
                  </div>
                  
                  <div class="selected-keywords" v-if="customKeywords.length">
                    <h4>已添加关键词：</h4>
                    <div class="keywords-container">
                      <span 
                        v-for="(keyword, index) in customKeywords" 
                        :key="index"
                        class="keyword-tag"
                      >
                        {{ keyword }}
                        <button class="remove-keyword" @click="removeKeyword(index)">×</button>
                      </span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="step-actions">
              <button class="prev-btn" @click="prevStep">上一步</button>
              <button class="next-btn" @click="nextStep" :disabled="!canProceedToStep2">下一步</button>
            </div>
          </div>
          
          <!-- 第三步：参数设置与生成 -->
          <div v-show="currentStep === 2" class="creation-step">
            <h3>参数设置与生成</h3>
            <div class="parameter-section">
              <div class="parameter-group">
                <h4>图片比例</h4>
                <div class="radio-group">
                  <label v-for="ratio in ratios" :key="ratio.value" class="radio-label">
                    <input 
                      type="radio" 
                      v-model="selectedRatio"
                      :value="ratio.value"
                      name="ratio"
                    >
                    {{ ratio.label }}
                  </label>
                </div>
              </div>
              
              <div class="parameter-group">
                <h4>分辨率</h4>
                <div class="radio-group">
                  <label v-for="resolution in resolutions" :key="resolution.value" class="radio-label">
                    <input 
                      type="radio" 
                      v-model="selectedResolution"
                      :value="resolution.value"
                      name="resolution"
                    >
                    {{ resolution.label }}
                  </label>
                </div>
              </div>
              
              <div class="generation-summary">
                <h4>创作摘要</h4>
                <div class="summary-content">
                  <p><strong>艺术风格：</strong>{{ selectedStyles.join(' + ') || '未选择' }}</p>
                  <p><strong>创作描述：</strong>{{ mainDescription || '无' }}</p>
                  <p><strong>自定义关键词：</strong>{{ customKeywords.length ? customKeywords.join('、') : '无' }}</p>
                  <p><strong>图片比例：</strong>{{ selectedRatio }}</p>
                  <p><strong>分辨率：</strong>{{ selectedResolution }}</p>
                </div>
              </div>
            </div>
            
            <div class="generation-actions">
              <button class="prev-btn" @click="prevStep">上一步</button>
              <button 
                class="generate-btn" 
                @click="generateArtwork"
                :disabled="isGenerating"
              >
                {{ isGenerating ? '生成中...' : '生成艺术作品' }}
              </button>
            </div>
            
            <!-- 生成状态 -->
            <div v-if="isGenerating" class="generation-status">
              <div class="loading-spinner"></div>
              <p>正在为您创作艺术作品，请稍候...</p>
            </div>
            
            <!-- 作品展示 -->
            <div v-if="artworkGenerated" class="artwork-section">
              <h3>我的艺术作品</h3>
              <div class="artwork-container">
                <div class="artwork-display">
                  <div class="artwork-placeholder" v-if="!generatedArtwork">
                    🎨
                  </div>
                  <img v-else :src="generatedArtwork" alt="生成的艺术作品" class="generated-artwork">
                </div>
                
                <div class="artwork-actions">
                  <button class="action-btn" @click="regenerateArtwork">重新生成</button>
                  <button class="action-btn primary" @click="saveArtwork">保存作品</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- 底部 -->
      <footer class="footer">
        <p>© 2025 AI 艺术创作平台 - 让创意无界，让 AI 赋能艺术创作</p>
      </footer>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import Navbar from '../components/Navbar.vue'
import { generatePainting, type PaintingParams } from '../api/creation'

const router = useRouter()

// 用户信息
const username = ref('')
const userInfo = ref<any>(null)

// 控制用户信息面板显示
const showUserProfile = ref(false)
// 用于延迟隐藏面板的定时器
const hideTimeout = ref<number | null>(null)

// 创作步骤
const currentStep = ref(0)
const steps = ref(['风格选择', '关键词引导', '参数生成'])

// 艺术风格标签
const artStyles = ref([
  '油画', '水彩', '素描', '国潮', '二次元', '像素艺术', '赛博朋克', '极简主义',
  '印象派', '抽象艺术', '写实主义', '卡通风格', '水墨画', '立体主义', '超现实主义', '波普艺术'
])

// 选中的风格
const selectedStyles = ref<string[]>([])

// 推荐关键词（根据选择的风格动态生成）
const recommendedKeywords = computed(() => {
  const keywords: string[] = []
  
  // 根据风格推荐关键词
  if (selectedStyles.value.includes('国潮')) {
    keywords.push('仙鹤', '祥云', '红灯笼', '书法字体', '古典纹样')
  }
  if (selectedStyles.value.includes('二次元')) {
    keywords.push('动漫人物', '大眼睛', '萌系', '樱花飘落', '校园场景')
  }
  if (selectedStyles.value.includes('赛博朋克')) {
    keywords.push('霓虹都市', '未来科技', '赛博空间', '电子屏幕', '机械朋克')
  }
  if (selectedStyles.value.includes('油画')) {
    keywords.push('厚重笔触', '丰富色彩', '光影层次', '古典质感', '艺术肌理')
  }
  if (selectedStyles.value.includes('水彩')) {
    keywords.push('透明质感', '色彩渐变', '湿润晕染', '轻盈梦幻', '柔和笔触')
  }
  if (selectedStyles.value.includes('像素艺术')) {
    keywords.push('像素方块', '复古游戏', '8-bit风格', '马赛克效果', '像素画风')
  }
  if (selectedStyles.value.includes('印象派')) {
    keywords.push('光影变幻', '户外风景', '笔触可见', '色彩明快', '捕捉瞬间')
  }
  if (selectedStyles.value.includes('抽象艺术')) {
    keywords.push('几何图形', '色块碰撞', '抽象表达', '情感符号', '非具象')
  }
  if (selectedStyles.value.includes('写实主义')) {
    keywords.push('细节刻画', '真实还原', '精准比例', '细腻质感', '照片级')
  }
  if (selectedStyles.value.includes('卡通风格')) {
    keywords.push('可爱角色', '简化线条', '鲜艳色彩', '夸张表情', '童趣风格')
  }
  if (selectedStyles.value.includes('水墨画')) {
    keywords.push('水墨晕染', '意境深远', '留白艺术', '笔墨韵味', '禅意美学')
  }
  if (selectedStyles.value.includes('极简主义')) {
    keywords.push('简约线条', '留白空间', '纯净色彩', '几何美学', '现代感')
  }
  if (selectedStyles.value.includes('立体主义')) {
    keywords.push('多视角', '几何分解', '重组形态', '平面立体', '抽象几何')
  }
  if (selectedStyles.value.includes('超现实主义')) {
    keywords.push('梦境场景', '奇幻组合', '超脱现实', '想象力', '神秘氛围')
  }
  if (selectedStyles.value.includes('波普艺术')) {
    keywords.push('流行文化', '鲜艳撞色', '重复图案', '漫画风格', '商业美学')
  }
  
  // 如果没有选择任何风格，提供通用推荐关键词
  if (keywords.length === 0) {
    keywords.push('唯美意境', '自然风光', '人物肖像', '城市景观', '艺术创意')
  }
  
  return [...new Set(keywords)] // 去重
})

// 主描述和自定义关键词
const mainDescription = ref('')
const customKeywords = ref<string[]>([])
const newKeyword = ref('')

// 参数设置
const ratios = ref([
  { label: '4:3', value: '4:3' },
  { label: '1:1', value: '1:1' },
  { label: '16:9', value: '16:9' },
  { label: '3:4', value: '3:4' }
])

const resolutions = ref([
  { label: '512×512', value: '512x512' },
  { label: '768×768', value: '768x768' },
  { label: '1024×1024', value: '1024x1024' }
])

const selectedRatio = ref('1:1')
const selectedResolution = ref('768x768')

// 生成状态
const isGenerating = ref(false)
const artworkGenerated = ref(false)
const generatedArtwork = ref('')

// 计算属性：是否可以进入下一步
const canProceedToStep1 = computed(() => {
  return selectedStyles.value.length > 0
})

const canProceedToStep2 = computed(() => {
  return mainDescription.value.trim() !== '' || customKeywords.value.length > 0
})

// 切换风格标签
const toggleStyle = (style: string) => {
  const index = selectedStyles.value.indexOf(style)
  if (index > -1) {
    selectedStyles.value.splice(index, 1)
  } else {
    selectedStyles.value.push(style)
  }
}

// 添加推荐关键词
const addKeyword = (keyword: string) => {
  if (!customKeywords.value.includes(keyword)) {
    customKeywords.value.push(keyword)
  }
}

// 添加自定义关键词
const addCustomKeyword = () => {
  if (newKeyword.value.trim() !== '' && !customKeywords.value.includes(newKeyword.value.trim())) {
    customKeywords.value.push(newKeyword.value.trim())
    newKeyword.value = ''
  }
}

// 移除关键词
const removeKeyword = (index: number) => {
  customKeywords.value.splice(index, 1)
}

// 下一步
const nextStep = () => {
  if (currentStep.value < 2) {
    currentStep.value++
  }
}

// 上一步
const prevStep = () => {
  if (currentStep.value > 0) {
    currentStep.value--
  }
}

// 生成艺术作品
const generateArtwork = async () => {
  isGenerating.value = true
  
  try {
    // 准备请求参数
    const params: PaintingParams = {
      styles: selectedStyles.value,
      description: mainDescription.value,
      keywords: customKeywords.value,
      ratio: selectedRatio.value,
      resolution: selectedResolution.value
    }
    
    console.log('发送生成请求:', params)
    
    // 调用后端 API
    const response = await generatePainting(params)
    
    console.log('API 响应:', response)
    
    if (response.data.code === 200 && response.data.data.image_url) {
      // 生成成功
      generatedArtwork.value = response.data.data.image_url
      artworkGenerated.value = true
      console.log('✅ 图片生成成功:', generatedArtwork.value)
    } else {
      // 生成失败
      console.error('生成失败:', response.data.message)
      alert('生成失败：' + response.data.message)
    }
  } catch (error: any) {
    console.error('生成错误:', error)
    
    // 如果后端接口还没有实现，使用占位图片
    if (error.response?.status === 404 || error.code === 'ERR_NETWORK') {
      console.warn('⚠️ 后端 API 不可用，使用占位图片')
      
      // 使用占位图片服务
      const width = selectedResolution.value.split('x')[0]
      const height = selectedResolution.value.split('x')[1]
      const seed = Date.now() + Math.floor(Math.random() * 1000)
      
      generatedArtwork.value = `https://picsum.photos/${width}/${height}?random=${seed}`
      artworkGenerated.value = true
      
      console.log('🖼️ 使用占位图片:', generatedArtwork.value)
    } else {
      alert('生成失败，请稍后再试')
    }
  } finally {
    isGenerating.value = false
  }
}

// 重新生成
const regenerateArtwork = () => {
  artworkGenerated.value = false
  generatedArtwork.value = ''
  generateArtwork()
}

// 保存作品
const saveArtwork = () => {
  alert('作品保存功能已触发')
}

// 跳转到个人中心
const goToProfile = () => {
  router.push('/profile')
}

// 跳转到登录页
const goToLogin = () => {
  router.push('/')
}

// 处理登出
const handleLogout = async () => {
  try {
    // 清除本地用户信息
    localStorage.removeItem('userInfo')
    userInfo.value = null
    username.value = ''
    
    // 跳转到登录页
    router.push('/')
  } catch (error: any) {
    console.error('退出失败:', error)
    // 即使失败也清空本地信息并跳转到登录页
    localStorage.removeItem('userInfo')
    userInfo.value = null
    username.value = ''
    router.push('/')
  }
}

// 添加延迟隐藏功能
const startHideTimer = () => {
  if (hideTimeout.value) {
    clearTimeout(hideTimeout.value)
  }
  hideTimeout.value = window.setTimeout(() => {
    showUserProfile.value = false
    hideTimeout.value = null
  }, 300) // 300ms延迟
}

// 取消隐藏定时器
const cancelHideTimer = () => {
  if (hideTimeout.value) {
    clearTimeout(hideTimeout.value)
    hideTimeout.value = null
  }
}

// 组件挂载时加载用户信息
// 组件挂载时加载用户信息
onMounted(() => {
  const storedUserInfo = localStorage.getItem('userInfo')
  if (storedUserInfo) {
    try {
      userInfo.value = JSON.parse(storedUserInfo)
      username.value = userInfo.value.username || '用户'
    } catch (e) {
      console.error('解析用户信息失败:', e)
    }
  } else {
    // 如果没有用户信息，可能是从其他地方跳转过来的
    username.value = '用户'
  }
})

// 计算属性获取当前路由
const currentRoute = computed(() => router.currentRoute.value.path)

// 组件挂载时的初始化
onMounted(() => {
  console.log('AI绘画创作页面已加载')
})
</script>

<style scoped>
.painting-container {
  position: relative;
  min-height: 100vh;
  width: 100vw;
}

.background-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #ffffff; /* 纯白色背景 */
  z-index: -1;
}

.content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* 导航栏样式 */
.navbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.nav-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo h1 {
  font-size: 24px;
  color: #667eea;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
}

.nav-links a {
  color: #333;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.3s;
  position: relative;
  padding: 8px 0;
}

.nav-links a:hover {
  color: #667eea;
}

.nav-links a.active {
  color: #667eea;
  font-weight: 600;
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #667eea;
  border-radius: 1px;
}

/* 下拉菜单 */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background: white;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  z-index: 1;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 0;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: #333;
  padding: 12px 24px;
  text-decoration: none;
  display: block;
  font-size: 14px;
  transition: all 0.3s;
}

.dropdown-content a:hover {
  background: #f5f5f5;
  color: #667eea;
}

.dropdown:hover .dropbtn {
  color: #667eea;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* 用户头像按钮样式 */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 用户信息悬浮面板 */
.user-profile-popup {
  position: absolute;
  top: 50px;
  right: 0;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
  margin-bottom: 12px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.profile-details {
  margin-bottom: 20px;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.profile-item:last-child {
  margin-bottom: 0;
}

.item-label {
  color: #666;
  font-size: 14px;
}

.item-value {
  color: #333;
  font-size: 14px;
  font-weight: 500;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-action-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.profile-action-btn:hover {
  background: #f5f5f5;
}

.profile-action-btn.logout {
  background: #fff5f5;
  color: #e53e3e;
}

.profile-action-btn.logout:hover {
  background: #ffebee;
}

.login-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  background: #667eea;
  color: white;
}

.login-btn:hover {
  background: #5568d3;
}

/* AI绘画页面主要内容 */
.painting-main {
  width: 100vw;
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.painting-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: #2D3E40;
  text-align: center;
  margin-bottom: 16px;
}

.page-description {
  font-size: 18px;
  color: #4A4A4A;
  text-align: center;
  margin-bottom: 40px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* 步骤指示器 */
.steps-indicator {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 50px;
  position: relative;
}

.steps-indicator::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 15%;
  right: 15%;
  height: 2px;
  background: #e0e0e0;
  z-index: 1;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.step-label {
  font-size: 16px;
  color: #999;
  font-weight: 500;
}

.step.active .step-number {
  background: #667eea;
  color: white;
}

.step.active .step-label {
  color: #667eea;
}

.step.completed .step-number {
  background: #4CAF50;
  color: white;
}

.step.completed .step-label {
  color: #4CAF50;
}

/* 创作步骤 */
.creation-step {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.creation-step h3 {
  font-size: 28px;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin-bottom: 30px;
}

/* 风格选择 */
.style-selection,
.keyword-guidance,
.parameter-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 30px;
}

.tag {
  background: #f0f0f0;
  color: #666;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.tag:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.tag.selected {
  background: #667eea;
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.recommendation-tag {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

.recommendation-tag:hover {
  background: rgba(102, 126, 234, 0.2);
}

.selected-combination {
  padding-top: 20px;
  border-top: 1px dashed #e0e0e0;
}

.selected-combination h4 {
  margin-bottom: 15px;
}

.combination-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.combination-tag {
  background: #667eea;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}

/* 关键词引导 */
.recommendation-section,
.input-section {
  margin-bottom: 30px;
}

.recommendation-section:last-child,
.input-section:last-child {
  margin-bottom: 0;
}

.recommendation-section h4,
.input-group h4 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
}

.description-input {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  resize: vertical;
  margin-bottom: 20px;
}

.keyword-input-area {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.keyword-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

.add-keyword-btn {
  padding: 12px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.add-keyword-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.selected-keywords {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed #e0e0e0;
}

.selected-keywords h4 {
  margin-bottom: 15px;
}

.keywords-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.keyword-tag {
  background: #667eea;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.remove-keyword {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  margin-left: 5px;
}

/* 参数设置 */
.parameter-group {
  margin-bottom: 30px;
}

.parameter-group:last-child {
  margin-bottom: 0;
}

.parameter-group h4 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #333;
  cursor: pointer;
}

.radio-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.generation-summary {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.generation-summary h4 {
  margin-bottom: 15px;
}

.summary-content p {
  margin-bottom: 10px;
  font-size: 16px;
  color: #555;
}

.summary-content strong {
  color: #333;
}

/* 操作按钮 */
.step-actions,
.generation-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 30px;
}

.prev-btn,
.next-btn,
.generate-btn,
.action-btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.prev-btn,
.action-btn {
  background: #f5f5f5;
  color: #666;
}

.prev-btn:hover,
.action-btn:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.next-btn,
.generate-btn {
  background: #667eea;
  color: white;
}

.next-btn:hover,
.generate-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.next-btn:disabled,
.generate-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-btn.primary {
  background: #4CAF50;
  color: white;
}

.action-btn.primary:hover {
  background: #45a049;
}

/* 生成状态 */
.generation-status {
  text-align: center;
  padding: 30px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.generation-status p {
  font-size: 18px;
  color: #666;
}

/* 作品展示 */
.artwork-section {
  margin-top: 40px;
  animation: fadeIn 0.5s ease;
}

.artwork-section h3 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.artwork-container {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.artwork-display {
  margin-bottom: 30px;
}

.artwork-placeholder {
  font-size: 120px;
  text-align: center;
  padding: 40px;
  background: #f8f9fa;
  border-radius: 8px;
}

.generated-artwork {
  width: 100%;
  border-radius: 8px;
}

.artwork-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* 底部 */
.footer {
  background: #333;
  color: white;
  text-align: center;
  padding: 40px 24px;
  margin-top: 80px;
  width: 100%;
}

.footer p {
  font-size: 14px;
  opacity: 0.8;
}

/* 响应式 */
@media (max-width: 768px) {
  .steps-indicator {
    gap: 15px;
  }
  
  .steps-indicator::before {
    left: 10%;
    right: 10%;
  }
  
  .step-label {
    font-size: 14px;
  }
  
  .creation-step h3 {
    font-size: 24px;
  }
  
  .style-selection,
  .keyword-guidance,
  .parameter-section {
    padding: 20px;
  }
  
  .tags-container {
    gap: 10px;
  }
  
  .tag {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  .radio-group {
    flex-direction: column;
    gap: 15px;
  }
  
  .keyword-input-area {
    flex-direction: column;
  }
  
  .step-actions,
  .generation-actions {
    flex-direction: column;
    gap: 15px;
  }
  
  .prev-btn,
  .next-btn,
  .generate-btn,
  .action-btn {
    width: 100%;
  }
  
  .artwork-container {
    padding: 20px;
  }
  
  .artwork-actions {
    flex-direction: column;
    gap: 15px;
  }
  
  .action-btn {
    width: 100%;
  }
}
</style>